Plots QSM cylinders using the rgl library
Usage
plot_qsm(
cylinder,
radius = NULL,
cyl_color = NULL,
cyl_palette = NULL,
cyl_sides = 8,
cloud = NULL,
pt_color = NULL,
pt_size = NULL,
axes = TRUE,
hover = FALSE,
skeleton = FALSE
)Arguments
- cylinder
QSM cylinder data frame
- radius
Vector of cylinder radii. Defaults to modified cylinders from the cylinder data frame.
- cyl_color
Optional cylinder color parameter. Colors must be a single hex color, or a vector or column of hex colors with the same length as the cylinder data frame.
- cyl_palette
Optional color palette for numerical data. Palettes include: viridis, inferno, plasma, magma, cividis, and rainbow.
- cyl_sides
The number of sides in the polygon cross section. Defaults to 8, but can be increased to improve visual smoothness.
- cloud
Point cloud data frame where the first three columns are the x, y, and z coordinates in the same coordinate system as the QSM.
- pt_color
Color of the point cloud. Defaults to black.
- pt_size
Size of the points as a number. Defaults to 0.1.
- axes
Show plot axes. Defaults to TRUE.
- hover
Show cylinder ID and branch on mouse hover. Defaults to FALSE.
- skeleton
Plot the QSM skeleton instead of cylinders for faster visualization. Defaults to FALSE.
Examples
# \donttest{
## TreeQSM Processing Chain
file <- system.file("extdata/QSM.mat", package = "rTwig")
qsm <- import_qsm(file)
#> Importing TreeQSM .mat
cylinder <- qsm$cylinder
cylinder <- update_cylinders(cylinder)
#> Updating Cylinder Ordering
#> Calculating Total Children
#> Building Cylinder Network
#> Calculating Growth Length
#> Calculating Reverse Branch Order
#> Calculating Branch Segments
#> Calculating Distance From Base
#> Calculating Average Distance To Twigs
cylinder <- correct_radii(cylinder, twig_radius = 4.23)
#> Generating Branch Paths
#> Starting Parallel Workers
#> Correcting Branch Paths
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"BranchOrder"` instead of `.data$BranchOrder`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"extension"` instead of `.data$extension`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"bad_fit3"` instead of `.data$bad_fit3`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"growthLength"` instead of `.data$growthLength`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"radius"` instead of `.data$radius`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"BranchOrder"` instead of `.data$BranchOrder`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"extension"` instead of `.data$extension`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"bad_fit3"` instead of `.data$bad_fit3`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"growthLength"` instead of `.data$growthLength`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"radius"` instead of `.data$radius`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"BranchOrder"` instead of `.data$BranchOrder`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"extension"` instead of `.data$extension`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"bad_fit3"` instead of `.data$bad_fit3`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"growthLength"` instead of `.data$growthLength`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"radius"` instead of `.data$radius`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"BranchOrder"` instead of `.data$BranchOrder`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"extension"` instead of `.data$extension`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"bad_fit3"` instead of `.data$bad_fit3`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"growthLength"` instead of `.data$growthLength`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"radius"` instead of `.data$radius`
#> Updating Cylinder Radii
#> Done!
plot_qsm(cylinder)
#> Plotting QSM
#> Creating Cylinder Meshes
#> Plotting Cylinder Meshes
## SimpleForest Processing Chain
file <- system.file("extdata/QSM.csv", package = "rTwig")
cylinder2 <- read.csv(file)
cylinder2 <- update_cylinders(cylinder2)
#> Calculating Total Children
#> Building Cylinder Network
#> Calculating Distance From Base
#> Calculating Average Distance To Twigs
cylinder2 <- correct_radii(cylinder2, twig_radius = 4.23)
#> Generating Branch Paths
#> Starting Parallel Workers
#> Correcting Branch Paths
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"branchOrder"` instead of `.data$branchOrder`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"ID"` instead of `.data$ID`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"bad_fit3"` instead of `.data$bad_fit3`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"growthLength"` instead of `.data$growthLength`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"radius"` instead of `.data$radius`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"branchOrder"` instead of `.data$branchOrder`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"ID"` instead of `.data$ID`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"bad_fit3"` instead of `.data$bad_fit3`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"growthLength"` instead of `.data$growthLength`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"radius"` instead of `.data$radius`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"branchOrder"` instead of `.data$branchOrder`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"ID"` instead of `.data$ID`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"bad_fit3"` instead of `.data$bad_fit3`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"growthLength"` instead of `.data$growthLength`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"radius"` instead of `.data$radius`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"branchOrder"` instead of `.data$branchOrder`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"ID"` instead of `.data$ID`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"bad_fit3"` instead of `.data$bad_fit3`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"growthLength"` instead of `.data$growthLength`
#> Warning: Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0.
#> ℹ Please use `"radius"` instead of `.data$radius`
#> Updating Cylinder Radii
#> Done!
plot_qsm(cylinder2)
#> Plotting QSM
#> Creating Cylinder Meshes
#> Plotting Cylinder Meshes
## All Parameters
file2 <- system.file("extdata/cloud.txt", package = "rTwig")
cloud <- read.table(file2, header = FALSE)
plot_qsm(
cylinder,
radius = cylinder$UnmodRadius,
cyl_color = cylinder$GrowthLength,
cyl_palette = "viridis",
cyl_sides = 100,
cloud = cloud,
pt_color = "white",
pt_size = 1,
axes = FALSE,
hover = TRUE
)
#> Plotting QSM
#> Creating Cylinder Meshes
#> Plotting Cylinder Meshes
3D plot